package com.tron.dobest.java.tronreflect;


import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Arrays;

public class Start {
    public static void main(String[] args) throws ClassNotFoundException {
        Class<?> aClass = Class.forName("com.tron.dobest.java.tronreflect.ReflectTestClass");
        Field[] publicFields = aClass.getFields();
        for (Field field : publicFields) {
            field.setAccessible(true);
            System.out.println(String.format("字段名称：%1$s,字段修饰符：%2$s,字段类型：%3$s",
                    field.getName(),
                    Modifier.toString(field.getModifiers()),
                    field.getGenericType()
            ));
        }
        System.out.println("======调皮的分割线======");
        Field[] fields = aClass.getDeclaredFields();
        for (Field field : fields) {
            field.setAccessible(true);
            System.out.println(String.format("字段名称：%1$s,字段修饰符：%2$s,字段类型：%3$s",
                    field.getName(),
                    Modifier.toString(field.getModifiers()),
                    field.getGenericType()
            ));
        }
        System.out.println("======调皮的分割线======");
        Method[] publicMethods = aClass.getMethods();
        for (Method method : publicMethods) {
            System.out.println(String.format("方法名称：%1$s,方法参数类型：%2$s,方法返回值类型：%3$s",
                    method.getName(),
                    Arrays.toString(method.getGenericParameterTypes()),
                    method.getReturnType()
            ));
        }
        System.out.println("======调皮的分割线======");
        Method[] methods = aClass.getDeclaredMethods();
        for (Method method : methods) {
            System.out.println(String.format("方法名称：%1$s,方法参数类型：%2$s,方法返回值类型：%3$s",
                    method.getName(),
                    Arrays.toString(method.getGenericParameterTypes()),
                    method.getReturnType()
            ));
        }
    }
}
